/*
 * @Description: 加入网约车PublicityIntroduction
 * @version: 
 * @Company: 
 * @Author: ZhengZhuang
 * @Date: 2019-08-21 16:15:25
 * @LastEditors: zhengzhuang
 * @LastEditTime: 2020-12-07 13:44:19
 */

import 'package:city_pickers/city_pickers.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:C20Driver/provider/position_information.dart';
import 'package:C20Driver/routers/navigator_util.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';

class PublicityIntroduction extends StatefulWidget {
  final String type;
  PublicityIntroduction({this.type});
  @override
  _PublicityIntroductionState createState() => _PublicityIntroductionState();
}

class _PublicityIntroductionState extends State<PublicityIntroduction> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.type == '0010' ? '加入网约车' : '加入顺风车'),
      ),
      backgroundColor: Color.fromARGB(255, 254, 253, 248),
      body: Stack(
        alignment: Alignment.topCenter,
        children: <Widget>[
          Positioned(
            top: -10,
            child: Image.asset(
              widget.type == '0010'
                  ? 'assets/icon/registered0010.png'
                  : 'assets/icon/registered0020.png',
              width: ScreenUtil().setWidth(750.0),
              height: ScreenUtil().setWidth(750.0),
            ),
          ),
          Positioned(
            top: ScreenUtil().setWidth(350),
            child: Container(
              width: ScreenUtil().setWidth(686),
              height: ScreenUtil().setHeight(670),
              padding: EdgeInsets.all(ScreenUtil().setWidth(32)),
              decoration: BoxDecoration(
                color: Color(0xffFFFFFF),
                borderRadius: BorderRadius.circular(ScreenUtil().setWidth(32)),
                boxShadow: <BoxShadow>[
                  BoxShadow(
                    color: Colors.black12,
                    blurRadius: ScreenUtil().setWidth(32.0),
                  ),
                ],
              ),
              child: SingleChildScrollView(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    getTextWith(
                        '01.车主条件', Color(0xff333333), FontWeight.w500, 30),
                    SizedBox(
                      height: ScreenUtil().setWidth(28),
                    ),
                    getTextWith('年龄：男21-60周岁，女21-55周岁', Color(0xff666666),
                        FontWeight.w400, 30),
                    SizedBox(
                      height: ScreenUtil().setWidth(10),
                    ),
                    getTextWith('驾驶证准驾车型：至少含A1、A2、B1、B2、C1、C2',
                        Color(0xff666666), FontWeight.w400, 30),
                    SizedBox(
                      height: ScreenUtil().setWidth(10),
                    ),
                    getTextWith('驾驶证出领日期：至今满3年以上', Color(0xff666666),
                        FontWeight.w400, 30),
                    SizedBox(
                      height: ScreenUtil().setWidth(20),
                    ),
                    getTextWith('无任何犯罪记录以及交通肇事、酒后驾驶、吸毒等记录', Color(0xff3FB956),
                        FontWeight.w500, 30),
                    SizedBox(
                      height: ScreenUtil().setWidth(80),
                    ),
                    getTextWith('02.自己带车加入车辆要求', Color(0xff333333),
                        FontWeight.w500, 30),
                    SizedBox(
                      height: ScreenUtil().setWidth(28),
                    ),
                    getTextWith('车辆注册日期（车龄）未满8年，旦行驶里程低于60万英里',
                        Color(0xff666666), FontWeight.w400, 30),
                    SizedBox(
                      height: ScreenUtil().setWidth(10),
                    ),
                    getTextWith('车辆所有人为公司时，需由车辆所属企业进行操作', Color(0xff666666),
                        FontWeight.w400, 30),
                    SizedBox(
                      height: ScreenUtil().setWidth(80),
                    ),
                    getTextWith('03.无车辆车主可购/租车加入', Color(0xff333333),
                        FontWeight.w500, 30),
                    SizedBox(
                      height: ScreenUtil().setWidth(28),
                    ),
                    getTextWith('您可通过C20平台购/租车加入', Color(0xff666666),
                        FontWeight.w400, 30),
                    SizedBox(
                      height: ScreenUtil().setWidth(20),
                    ),
                    getTextWith('您可拨打客服热线进行详细咨询：', Color(0xff3FB956),
                        FontWeight.w500, 30),
                    SizedBox(
                      height: ScreenUtil().setWidth(20),
                    ),
                    InkWell(
                      child: getTextWith('400-089-3089', Color(0xff3FB956),
                          FontWeight.w500, 30),
                      onTap: () => _makePhoneCall('tel:${4000893089}'),
                    ),
                  ],
                ),
              ),
            ),
          ),
          Positioned(
            bottom: 0,
            left: 0,
            child: _bottomJoin(),
          )
        ],
      ),
    );
  }

  _makePhoneCall(url) async {
    if (await canLaunch(url)) {
      await launch(url);
    } else {
      throw 'Could not launch $url';
    }
  }

  Widget getTextWith(String text, Color color, FontWeight weight, num font) {
    return Text(
      text,
      style: TextStyle(
          color: color, fontSize: ScreenUtil().setSp(font), fontWeight: weight),
    );
  }

  /// 底部加入栏
  Widget _bottomJoin() {
    return Container(
      width: ScreenUtil().setWidth(750.0),
      height: ScreenUtil().setHeight(150.0),
      padding: EdgeInsets.only(
          left: ScreenUtil().setWidth(32.0),
          right: ScreenUtil().setWidth(32.0),
          top: ScreenUtil().setWidth(32)),
      decoration: BoxDecoration(
        color: Colors.white,
        boxShadow: <BoxShadow>[
          new BoxShadow(
            color: Color.fromARGB(50, 0, 0, 0),
            blurRadius: 1.0,
          ),
        ],
      ),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          InkWell(
            child: Container(
              width: ScreenUtil().setWidth(230.0),
              height: ScreenUtil().setWidth(80.0),
              decoration: BoxDecoration(
                color: Color(0xffFFFFFF),
              ),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Image.asset(
                    'assets/icon/icon_fill_dingwei.png',
                    width: ScreenUtil().setWidth(48),
                    height: ScreenUtil().setWidth(48),
                  ),
                  SizedBox(width: ScreenUtil().setWidth(10)),
                  Container(
                    width: ScreenUtil().setWidth(120.0),
                    alignment: Alignment.centerLeft,
                    child: Consumer<PositionInformation>(
                        builder: (ctx, state, child) {
                      return Text(
                        '${state.driverCurrentCity}',
                        overflow: TextOverflow.ellipsis,
                        maxLines: 2,
                        style: TextStyle(
                          fontSize: ScreenUtil().setSp(35.0),
                          color: Colors.black,
                        ),
                      );
                    }),
                  ),
                  Icon(Icons.chevron_right)
                ],
              ),
            ),
            onTap: () async {
              Result result2 = await CityPickers.showFullPageCityPicker(
                context: context,
              );
              Provider.of<PositionInformation>(context, listen: false)
                  .setCityName(result2.areaName);
            },
          ),
          SizedBox(width: ScreenUtil().setWidth(64.0)),
          Expanded(
            child: InkWell(
              child: Container(
                alignment: Alignment.center,
                decoration: BoxDecoration(
                  color: Color(0xff3FB956),
                  borderRadius: BorderRadius.circular(42.0),
                ),
                height: ScreenUtil().setWidth(100.0),
                child: Text(
                  widget.type == '0010' ? '加入网约车' : '加入顺风车',
                  style: TextStyle(
                      fontSize: ScreenUtil().setSp(30.0),
                      color: Colors.white,
                      fontWeight: FontWeight.w500),
                ),
              ),
              onTap: () {
                NavigatorUtil.jump(
                    context, '/authenticationAudit?type=${widget.type}');
              },
            ),
          )
        ],
      ),
    );
  }
}
